# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>
# Contributor: Konstantin Shalygin <k0ste@k0ste.ru>

pkgname=xmrig
pkgver=6.21.0
pkgrel=1
pkgdesc='RandomX, KawPow, CryptoNight, AstroBWT and GhostRider unified CPU/GPU miner and RandomX benchmark'
url='https://github.com/xmrig/xmrig'
arch=('loong64' 'x86_64')
license=('GPL3')
depends=('libuv' 'openssl' 'hwloc')
makedepends=('cmake')
backup=("etc/${pkgname}/${pkgname}.conf")
source=(https://github.com/xmrig/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        xmrig@.service
        xmrig.sysusers)
sha256sums=('4b197c71fa06030216b641b4ea57f7a3d977a17df1b55bd13759d4705dbf5941'
            'bbc54b04a7da5ea473eb7d976307eb995fbfd96f0d012f1553b8c487182d9fb3'
            'd8f499302fb2b642fe02586c81c410a299e0a6e133aef1cc1c783bcdcb3f44f6')

prepare() {
  cd "${pkgname}-${pkgver}"
  mkdir -p build
}

build() {
  cd "${pkgname}-${pkgver}/build"
  cmake .. -DCMAKE_BUILD_TYPE=Release
  make
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm775 "build/${pkgname}" -t "${pkgdir}/usr/bin"
  install -Dm644 "src/config.json" "${pkgdir}/etc/${pkgname}/xmrig.conf"
  install -Dm644 "${srcdir}/${pkgname}@.service" -t "${pkgdir}/usr/lib/systemd/system"
  install -Dm0644 "${srcdir}/${pkgname}.sysusers" -t "${pkgdir}/usr/lib/sysusers.d"
}

# vim: ts=2 sw=2 et:
